import { IPSApplication } from '../../app/ipsapplication';
import { IPSAppWF } from '../../app/wf/ipsapp-wf';
import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDECancelWFLogic } from './ipsdecancel-wflogic';
import { IPSDELogic } from './ipsdelogic';
import { IPSDELogicParam } from './ipsdelogic-param';
import { PSDELogicNodeImpl } from './psdelogic-node-impl';
import { IPSDEWF } from '../wf/ipsdewf';
import { IPSWorkflow } from '../../wf/ipsworkflow';

export class PSDECancelWFLogicImpl extends PSDELogicNodeImpl implements IPSDECancelWFLogic {
  protected dstpsdelogicparam: IPSDELogicParam | null = null;

  getDstPSDELogicParam(): IPSDELogicParam | null {
    if (this.dstpsdelogicparam != null) return this.dstpsdelogicparam;
    const value = this.M.getDstPSDELogicParam;
    if (value == null) {
      return null;
    }
    const ipsdelogic = this.getParentPSModelObject('dataentity.logic.IPSDELogic') as IPSDELogic;
    if (ipsdelogic != null) {
      this.dstpsdelogicparam = ipsdelogic.findPSDELogicParam(value);
    }
    return this.dstpsdelogicparam;
  }

  get dstPSDELogicParam(): IPSDELogicParam | null {
    return this.getDstPSDELogicParam();
  }

  getDstPSDELogicParamMust(): IPSDELogicParam {
    const value = this.getDstPSDELogicParam();
    if (value == null) {
      throw new Error('未指定目标逻辑参数对象');
    }
    return value;
  }

  protected dstpsdataentity: IPSDataEntity | null = null;

  getDstPSDataEntity(): IPSDataEntity | null {
    if (this.dstpsdataentity != null) return this.dstpsdataentity;
    const value = this.M.getDstPSDataEntity;
    if (value == null) {
      return null;
    }
    this.dstpsdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getDstPSDataEntity') as IPSDataEntity;
    return this.dstpsdataentity;
  }

  get dstPSDataEntity(): IPSDataEntity | null {
    return this.getDstPSDataEntity();
  }

  getDstPSDataEntityMust(): IPSDataEntity {
    const value = this.getDstPSDataEntity();
    if (value == null) {
      throw new Error('未指定目标实体对象');
    }
    return value;
  }

  protected psappwf: IPSAppWF | null = null;

  getPSAppWF(): IPSAppWF | null {
    if (this.psappwf != null) return this.psappwf;
    const value = this.M.getPSAppWF;
    if (value == null) {
      return null;
    }
    const ipsapplication = this.getParentPSModelObject('app.IPSApplication') as IPSApplication;
    if (ipsapplication != null) {
      this.psappwf = ipsapplication.findPSAppWF(value);
    }
    return this.psappwf;
  }

  get psAppWF(): IPSAppWF | null {
    return this.getPSAppWF();
  }

  getPSAppWFMust(): IPSAppWF {
    const value = this.getPSAppWF();
    if (value == null) {
      throw new Error('未指定应用工作流对象');
    }
    return value;
  }

  protected psdewf: IPSDEWF | null = null;

  getPSDEWF(): IPSDEWF | null {
    if (this.psdewf != null) return this.psdewf;
    const value = this.M.getPSDEWF;
    if (value == null) {
      return null;
    }
    this.psdewf = this.getPSWorkflowMust().findPSWFDE(value);
    return this.psdewf;
  }

  get psDEWF(): IPSDEWF | null {
    return this.getPSDEWF();
  }

  getPSDEWFMust(): IPSDEWF {
    const value = this.getPSDEWF();
    if (value == null) {
      throw new Error('未指定实体工作流对象');
    }
    return value;
  }

  protected psworkflow: IPSWorkflow | null = null;

  getPSWorkflow(): IPSWorkflow | null {
    if (this.psworkflow != null) return this.psworkflow;
    const value = this.M.getPSWorkflow;
    if (value == null) {
      return null;
    }
    this.psworkflow = this.getPSModel4('wf.IPSWorkflow', value, 'getPSWorkflow') as IPSWorkflow;
    return this.psworkflow;
  }

  get psWorkflow(): IPSWorkflow | null {
    return this.getPSWorkflow();
  }

  getPSWorkflowMust(): IPSWorkflow {
    const value = this.getPSWorkflow();
    if (value == null) {
      throw new Error('未指定工作流对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSDECancelWFLogicImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.logic.IPSDECancelWFLogic') return true;
    return super.instanceof(cls);
  }
}
